<%@page import="java.util.*" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
    <form action="">
        <input type="text" class="username">
        <span class="errors"></span>
        <input type="button"  value="提交"onclick="test1()">
    </form>

    <script>
        function test1() {
          $.ajax({
              type:'post',
              data:{"username":$(".username").val()},
              url:"/fashion/TestServlet?method=test",
              success:function (data) {
                  alert(data);
              },
              error:function (data) {
                  alert(data)
              }
          });
        }
    </script>

</body>
</html>